import { CommonEntity } from '../../../../common/entities/common.entity';
import { Column, Entity } from 'typeorm';

export enum AccountType {
  ADMIN = 'admin',
  USER = 'user',
}

@Entity({
  name: 'sys_login_log',
  comment: '登录日志表',
})
export class LoginLog extends CommonEntity {
  @Column({
    name: 'login_ip',
    length: 10,
    type: 'varchar',
    comment: '登录IP',
  })
  loginIp: string;

  @Column({
    name: 'login_address',
    length: 50,
    type: 'varchar',
    comment: '登录地址',
  })
  loginAddress: string;

  @Column({
    name: 'account_type',
    type: 'enum',
    enum: AccountType,
    default: AccountType.USER,
    comment: '账号类型',
  })
  accountType: AccountType;

  @Column({
    name: 'account_id',
    type: 'uuid',
    comment: 'adminId or userId',
  })
  accountId: string;
}
